package com.lihui.model;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2022/11/05  14:18
 */
public class Student implements Comparable<Student>{
    private String name;
    private int number;
    private int age;
    private int credit;

    public Student() {
    }

    public Student(String name, int number, int age, int credit) {
        this.name = name;
        this.number = number;
        this.age = age;
        this.credit = credit;
    }
    /**
//重写equals方法
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || !(obj instanceof Student)) {
            return false;
        }
        Student student = (Student) obj;
        if (this.age != student.getAge()) {
            return false;
        }
        if (!this.name.equals(student.getName())) {
            return false;
        }
        if (this.number != student.getNumber()) {
            return false;
        }
        if (this.credit != student.getCredit()) {
            return false;
        }
        return true;
    }


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", number=" + number +
                ", age=" + age +
                ", credit=" + credit +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    public String getName() {
        return name;
    }

    public int getNumber() {
        return number;
    }

    public int getAge() {
        return age;
    }

    public int getCredit() {
        return credit;
    }
    /**
  实现 Comparable接口，重写compareTo方法
     */
    @Override
    public int compareTo(Student o) {
        return this.number - o.number;
    }
}
